import type { Student } from './student'
import http from '@/utils/http'

export interface Lesson {
  id: string
  classId: string
  campusId: string
  classroomId: string
  leadTeacherId: string
  assistTeacherId?: string
  lessonIndex: number
  title: string
  lessonDate: string
  startTime: string
  endTime: string
  lessonStatus: number
  arrangeLessonId: string
  description?: string
  remark?: string
}

export interface LessonStudent {
  id: string
  enrollmentId: string
  lessonClassId: string
  studentClassId: string
  lessonId: string
  studentId: string
  studentClassStatus: number
  operateSource: string
  signInTime?: string
  signInStatus: boolean
  studentJoinType: number
  lessonHour: number
  lessonPrice: number
  orderItemId: string
  remark?: string
}

export interface LessonStudentDetailResp extends LessonStudent {
  student: Student
}

export interface LessonSignInReq {
  lessonId: string
  studentIdList: string[]
}

export interface LessonStudentQuery {
  lessonId: string
  studentClassStatus?: number
}

export interface LessonUpdateReq {
  title?: string
  classId?: string
  classroomId?: string
  campusId?: string
  leadTeacherId?: string
  assistTeacherId?: string
  lessonDate?: string
  startTime?: string
  endTime?: string
  lessonStatus?: number
  description?: string
}

export const updateLesson = (req: LessonUpdateReq, lessonId: string) => {
  return http.post(`/education/class/lesson/update/${lessonId}`, req)
}

export const signIn = (req: LessonSignInReq) => {
  return http.post(`/education/class/lesson/signIn`, req)
}

export const unSignIn = (req: LessonSignInReq) => {
  return http.post(`/education/class/lesson/unSignIn`, req)
}

export const getLessonStudentList = (query: LessonStudentQuery) => {
  return http.get<LessonStudentDetailResp[]>(`/education/class/lesson/student/list`, query)
}
